package main

import (
	"encoding/json"
	"fmt"
	"net"
)

type loginInfo struct {
	Id       int
	Number   string
	Password string
	Status   int
}

type SerMessage struct {
	kind string
	data interface{}
}

func delCon(con net.Conn) {
	defer con.Close()
	buf := make([]byte, 1024)
	n, err := con.Read(buf)
	if err != nil {
		fmt.Println("读取数据失败", err)
		return
	}
	data := string(buf[0:n])

	mes := &SerMessage{
		kind: "",
		data: loginInfo{
			Number:   "",
			Password: "",
		},
	}

	json.Unmarshal([]byte(data), mes)
	switch mes.kind {
	case "login":
		doLogin(con, mes.data.(loginInfo))
	default:
		fmt.Println("else instructions")
	}
}
